<html>
	<head>
	<title>Docs Poller</title>
	<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
		<script type="text/javascript">
			
			function makeHttpObject() {
			  try {return new XMLHttpRequest();}
			  catch (error) {}
			  try {return new ActiveXObject("Msxml2.XMLHTTP");}
			  catch (error) {}
			  try {return new ActiveXObject("Microsoft.XMLHTTP");}
			  catch (error) {}

			  throw new Error("Could not create HTTP request object.");
			}
		</script>


	</head>
	<body>
		<div id="wrapper">
			<div id="page">
				<div id="page-bgtop">
					<div id="page-bgbtm">
						<div id="content">
							<div class="post">
								<h2 class="title" style="text-align:center" >Welcome to DocsPoller!</h2>
							</div>
							<table border="0" cellspacing="1" cellpadding="2" bgcolor="#FFFFFF" width="450">
								<tbody>
									<tr>
									<!--
										<td class="table1" align="left">
											<div class="post" id="radioButtons">
												<input type="radio" name="radioCRUD" value="POST">POST<br>
												<input type="radio" name="radioCRUD" value="GET">GET<br>
												<input type="radio" name="radioCRUD" value="PUT">PUT<br>
												<input type="radio" name="radioCRUD" value="DELETE">DELETE<br>
											</div>
										</td>
										
										<td class="table2">
											<div class="post" id="keyInputs">
												<p><b>Country: </b></p>
												<p><b>Department: </b></p>
												<p><b>Center: </b></p>
												<p><b>Polling Station: </b></p>
												<p><b>Candidate: </b></p>
												<p><b>Votes: </b></p>
											</div>
										<br></td>
										-->
										<td class="table3">
											<div class="post" id="keyInputs">
												<input type="text" id="keyInputStation" value="PollingStation"><br>
												<input type="text" id="keyInputNum" value="100"><br>
												<input type="text" id="keyInputCandidate1" value="Reyes"><br>
												<input type="text" id="keyInputVotes1" value="5"><br>
												<input type="text" id="keyInputCandidate2" value="Jojoy"><br>
												<input type="text" id="keyInputVotes2" value="3"><br>
												<input type="text" id="keyInputCandidate3" value="Piedad"><br>
												<input type="text" id="keyInputVotes3" value="0"><br>
											</div>
										</td>
									</tr>
								</tbody>
							</table>
							<div class="post">
								<div class="entry",id="entry">
									<p><button id="buttonPost">Add voting table</button></p>
										<script type="text/javascript">
											document.getElementById("buttonPost").onclick = function()
											{
												var objt = {};
												var request = makeHttpObject();
												objt.table = document.getElementById("keyInputStation").value;
												objt.tablenum = document.getElementById("keyInputNum").value;
												objt.cd1 = document.getElementById("keyInputCandidate1").value;
												objt.cd2 = document.getElementById("keyInputCandidate2").value;
												objt.cd3 = document.getElementById("keyInputCandidate3").value;
												objt.votes1 = document.getElementById("keyInputVotes1").value;
												objt.votes2 = document.getElementById("keyInputVotes2").value;
												objt.votes3 = document.getElementById("keyInputVotes3").value;
												
												request.open("POST", "http://127.0.0.1:9292/database", true);
												request.send(JSON.stringify(objt));
												request.onreadystatechange = function() {
												  if (request.readyState == 4)
													console.log(request.responseText.length);
												};
											}
										</script>
									<p><button id="buttonUpdate">Update voting table</button></p>
									<script type="text/javascript">
										document.getElementById("buttonUpdate").onclick = function()
										{
											var objt = {};
											var request = makeHttpObject();
											objt.table = document.getElementById("keyInputStation").value;
											objt.tablenum = document.getElementById("keyInputNum").value;
											objt.cd1 = document.getElementById("keyInputCandidate1").value;
											objt.cd2 = document.getElementById("keyInputCandidate2").value;
											objt.cd3 = document.getElementById("keyInputCandidate3").value;
											objt.votes1 = document.getElementById("keyInputVotes1").value;
											objt.votes2 = document.getElementById("keyInputVotes2").value;
											objt.votes3 = document.getElementById("keyInputVotes3").value;
											
											request.open("PUT", "http://127.0.0.1:9292/database", true);
											request.send(JSON.stringify(objt));
											request.onreadystatechange = function() {
											  if (request.readyState == 4)
												console.log(request.responseText.length);
											};
										}
									</script>
									<p><button id="buttonDel">Delete voting table</button></p>
									<script type="text/javascript">
										document.getElementById("buttonDel").onclick = function()
										{
											var objt = {};
											var request = makeHttpObject();
											objt.table = document.getElementById("keyInputStation").value;
											objt.tablenum = document.getElementById("keyInputNum").value;
											objt.cd1 = document.getElementById("keyInputCandidate1").value;
											objt.cd2 = document.getElementById("keyInputCandidate2").value;
											objt.cd3 = document.getElementById("keyInputCandidate3").value;
											objt.votes1 = document.getElementById("keyInputVotes1").value;
											objt.votes2 = document.getElementById("keyInputVotes2").value;
											objt.votes3 = document.getElementById("keyInputVotes3").value;
											
											request.open("DELETE", "http://127.0.0.1:9292/database", true);
											request.send(JSON.stringify(objt));
											request.onreadystatechange = function() {
											  if (request.readyState == 4)
												console.log(request.responseText.length);
											};
										}
									</script>
								</div>
							</div>
							<div class="post">
								<div class="entry">
									<p>click <a href="https://spreadsheets.google.com/pub?key=0Amhf1qkV0GFFdEE2VnZFRlZsVW05a3Y0ckpIMy1mNnc&hl">here.</a></p>
								</div>
							</div>
						</div>
						<div style="clear: both;">&nbsp;</div>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>